using System;
using MonoTouch.Foundation;

namespace Ro.Norc.ServiceStackClient
{
	/// <summary>
	/// Custom argument for the ServiceError event
	/// </summary>
	public class ServiceErrorArgs : EventArgs
	{
		/// <summary>
		/// The underlying NSError object
		/// </summary>
		private NSError _error = null;
		
		private object _state = null;
		
		/// <summary>
		/// Creates a new ServiceErrorArgs object
		/// </summary>
		/// <param name="error">
		/// The underlying NSError object
		/// </param>
		public ServiceErrorArgs (NSError error) : base()
		{
			if (error == null) {
				throw new ArgumentNullException("error");
			}
			_error = error;
		}
		
		public ServiceErrorArgs (NSError error, object state) : this(error) 
		{
			_state = state;
		}
		
		/// <summary>
		/// Gets the error code
		/// </summary>
		public int Code
		{
			get {
				return _error.Code;
			}
		}
		
		/// <summary>
		/// Gets the error domain
		/// </summary>
		public string Domain
		{
			get {
				return _error.Domain;
			}
		}
		
		/// <summary>
		/// Gets the error description
		/// </summary>
		public string Description
		{
			get {
				return _error.LocalizedDescription;
			}
		}
		
		public object State
		{
			get {
				return _state;
			}
		}
	}
}